package sixkey.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import sixkey.domain.entity.UserPermiss;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import sixkey.mapper.UserPermissMapper;
import sixkey.service.IUserPermissService;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author sixkey
 * @since 2023-06-22
 */
@Service
public class UserPermissServiceImpl extends ServiceImpl<UserPermissMapper, UserPermiss> implements IUserPermissService {

    @Override
    public List<Integer> getPermissIdByUserId(long userId) {
        LambdaQueryWrapper<UserPermiss> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserPermiss::getUserId,userId);
        List<UserPermiss> userPermisses = baseMapper.selectList(wrapper);
        List<Integer> permissionList = userPermisses.stream().map(item -> item.getPermissId()).collect(Collectors.toList());
        return permissionList;
    }
}
